home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / libc / Quad_AddUns.c < prev    next >
C/C++ Source or Header  |  1991-03-18  |  2KB  |  57 lines

  1. /* 
  2.  * Quad_AddUns.c --
  3.  *
  4.  *    Quad_AddUns libc routine.
  5.  *
  6.  * Copyright 1991 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that this copyright
  10.  * notice appears in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/quad/RCS/Quad_AddUns.c,v 1.1 91/03/18 12:18:49 kupfer Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20. #include <quad.h>
  21.  
  22.  
  23. /*
  24.  *----------------------------------------------------------------------
  25.  *
  26.  * Quad_AddUns --
  27.  *
  28.  *    Add an unsigned quad to another unsigned quad.  The temporary 
  29.  *    variable is needed so that a u_quad can be added to itself.
  30.  *
  31.  * Results:
  32.  *    The sum of the 2 arguments.
  33.  *
  34.  * Side effects:
  35.  *    None.
  36.  *
  37.  *----------------------------------------------------------------------
  38.  */
  39.     
  40. void
  41. Quad_AddUns(uQuad1, uQuad2, resultPtr)
  42.     u_quad uQuad1;        /* in */
  43.     u_quad uQuad2;        /* in */
  44.     u_quad *resultPtr;        /* out */
  45. {
  46.     unsigned long newLeastSig;    /* new least significant word */
  47.  
  48.     newLeastSig = uQuad1.val[QUAD_LEAST_SIG] + uQuad2.val[QUAD_LEAST_SIG]; 
  49.     resultPtr->val[QUAD_MOST_SIG] = uQuad1.val[QUAD_MOST_SIG]
  50.         + uQuad2.val[QUAD_MOST_SIG];
  51.     if (newLeastSig < uQuad1.val[QUAD_LEAST_SIG]
  52.         && newLeastSig < uQuad2.val[QUAD_LEAST_SIG]) {
  53.     resultPtr->val[QUAD_MOST_SIG]++; 
  54.     }
  55.     resultPtr->val[QUAD_LEAST_SIG] = newLeastSig; 
  56. }
  57.